package cn.jhz.learn.blog.controller.core.open;

import cn.jhz.learn.blog.service.core.open.file.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;

@RestController
@RequestMapping("/api/public/core/file/picture/")
public class FileController {

    private final FileService fileService;

    @Autowired
    public FileController(FileService fileService) {
        this.fileService = fileService;
    }

    @GetMapping("{signature_codes}")
    public StreamingResponseBody picture(@PathVariable("signature_codes") String signatureCodes){
        return fileService.download(signatureCodes);
    }
}
